package com.haochu.novel.ui;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;

import com.example.testnovel.R;

/**
 * @author fuhuichao
 * 2017年7月7日11:55:28
 * 全文搜素
 */
public class BookSearchWordActivity extends Activity implements OnClickListener, OnItemClickListener, TextWatcher {

	// 资源视图
	private EditText search_input;
	private Button search_cancel;
	private ListView search_result;
	// 自定义adapter
	private MyAdapter myAdapter;
	// 列表数据集合
//	private list results;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//设置无标题  
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
        //设置全屏
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 
        
        setContentView(R.layout.layout_book_search_word);
		
        // 初始化资源
        search_input = (EditText) findViewById(R.id.search_input);
        search_cancel = (Button) findViewById(R.id.search_cancel);
        search_result = (ListView) findViewById(R.id.search_result);
        search_input.addTextChangedListener(this);
        search_cancel.setOnClickListener(this);
        search_result.setOnItemClickListener(this);
		
//        myAdapter = new MyAdapter();
//        search_result.setAdapter(myAdapter);
        
	}

	@Override public void onClick(View v) {
		switch (v.getId()) {
		case R.id.search_cancel:
			finish();
			break;
		default:
			break;
		}
	}

	@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		
	}

	@Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
	@Override public void afterTextChanged(Editable s) {}

	/**
	 * 文字改变监听
	 */
	@Override public void onTextChanged(CharSequence s, int start, int before, int count) {
//		Log.d("iiii", s.toString());
		
	}


	

	/**
	 * 自定义adapter
	 */
	class MyAdapter extends BaseAdapter{

		@Override
		public int getCount() {
			return 0;
		}

		@Override
		public Object getItem(int position) {
			return null;
		}

		@Override
		public long getItemId(int position) {
			return 0;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parent) {
			return null;
		}
		
	}
}
